package com.bluesky.drcp.persistence.dao.ibatis;

import java.sql.SQLException;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.bluesky.drcp.business.UserRole;
import com.bluesky.drcp.persistence.dao.UserRoleDao;

public class UserRoleDaoImpl extends SqlMapClientDaoSupport implements UserRoleDao{

	public void delete(String userId) {
		try{
			getSqlMapClient().delete("deleteByUserId", userId);
		}
		catch(SQLException se)
		{
			throw new RuntimeException(se.getMessage());
		}
	}

	public List getRoleList(String userId) {
		
		try{
			return getSqlMapClient().queryForList("findRolesByUserId", userId);
		}
		catch(SQLException se)
		{
			throw new RuntimeException(se.getMessage());
		}
	}

	public void save(UserRole userRole) {
		try{
			getSqlMapClient().insert("insertUserRole", userRole);
		}
		catch(SQLException se)
		{
			throw new RuntimeException(se.getMessage());
		}
		
	}

}
